//
//  MStore.m
//  RRQS
//
//  Created by kyjun on 16/3/28.
//
//

#import "MStore.h"
#import "MFood.h"

@implementation MStore

-(instancetype)initWithItem:(NSDictionary *)item{
    self = [super init];
    if(self){
        _rowID = [item objectForKey:@"itemid"];
        _storeID = [item objectForKey:@"site_id"];
        _storeName = [item objectForKey:@"site_name"];
        _storePhone = [item objectForKey:@"site_phone"];
        _storeAddress = [item objectForKey:@"site_addr"];
      //  _lng = [item objectForKey:@"lng"];
     //   _lat = [item objectForKey:@"lat"];
          _lng = [item objectForKey:@"longitude"];
           _lat = [item objectForKey:@"latitude"];
        _phoneAddress = [item objectForKey: @"phone_addr"];
        _userName = [item objectForKey:@"uname"];
        _userPhone = [item objectForKey:@"phone"];
        
        _orderID = [item objectForKey:@"main_id"];
        _subOrderID = [item objectForKey:@"order_id"];
        _createDate = [item objectForKey:@"add_time"];
        _sumMoney = [item objectForKey:@"food_amount"];
        _payType = [item objectForKey:@"paytype"];
        _status = [[item objectForKey:@"status"] integerValue];
      
        _empID = [item objectForKey:@"emp_id"];
        _location = [item objectForKey:@"location"];
        
        NSArray* array = [item objectForKey:@"foods"];
        if(![WMHelper isNULLOrnil:array]){
            [array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                MFood* sub = [[MFood alloc]initWithItem:obj];
                [self.arrayGoods addObject:sub];
            }];
        }
    }
    return self;
}


-(NSMutableArray *)arrayGoods{
    if(!_arrayGoods){
        _arrayGoods = [[NSMutableArray alloc]init];
    }
    return _arrayGoods;
}

-(NSString *)payType{
    if([_payType isEqualToString:@"0"]){
        return @"现金支付";
    }else if ([_payType isEqualToString:@"1"]){
        return @"支付宝支付";
    }
    else if ([_payType isEqualToString:@"2"]){
        return @"微信支付";
    }
    else if ([_payType isEqualToString:@"3"]){
        return @"手机支付宝";
    }
    return @"其它支付";
}
@end
